/*
 * @Description:
 * @Version: 2.0
 * @Autor: zhangjx
 * @Date: 2023-03-11 14:37:18
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2024-05-25 13:04:55
 */
import { request } from './axios'

const importModules = import.meta.glob('./modules/*.ts', { eager: true })
const apiGenerators = Object.keys(importModules).map(
  (key) => importModules[key] || {}
)
let api: any = {}
apiGenerators.forEach((generator: any) => {
  const apiInstance = generator.default({
    request
  })
  for (const apiName in apiInstance) {
    if (Object.prototype.hasOwnProperty.call(apiInstance, apiName)) {
      api[apiName] = apiInstance[apiName]
    }
  }
})

export default api
